package cn.weakup.designpattern.b_creational.factory.simplefactory;

/**
 * @author lixj
 * @version 1.0.0
 * @date 2022/6/2
 * @desc
 */
public class OperationFactory {

    public static Operation createOperate(String option) {
        Operation operation = null;
        switch (option) {
            case "+":
                operation = new OperationAdd();
                break;
            case "-":
                operation = new OperationSub();
                break;
            case "*":
                operation = new OperationMul();
                break;
            case "/":
                operation = new OperationDiv();
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + option);
        }
        return operation;
    }
}
